#include "chart_db.h"

void Chart_DB::paintChart(QPainter & p)
{
    QPen tmp = p.pen();
    p.setPen(paintChartDrawPen);

    int sx = paintStart.rx(),sy = paintStart.ry(),ex = paintEnd.rx(),ey = paintEnd.ry();

    int d = ex - sx; // 直径
    if(graphPath) delete graphPath;
    graphPath = new QPainterPath;



    graphPath->moveTo(sx + (d / 10) ,sy);
    graphPath->lineTo(ex - (d / 10) ,sy);
    graphPath->lineTo(ex - (d / 10) ,ey);
    graphPath->lineTo(sx + (d / 10) ,ey);
    graphPath->lineTo(sx + (d / 10) ,sy);
    p.fillPath(*graphPath,paintChartFillPen);
    p.drawPath(*graphPath);



    graphPath = new QPainterPath;
    graphPath->addEllipse(sx,sy,d / 5,ey - sy); // 添加一个椭圆
    graphPath->addEllipse(ex - d / 5,sy,d / 5,ey - sy); // 添加一个椭圆


    p.fillPath(*graphPath,paintChartFillPen);
    p.drawPath(*graphPath);


    p.setPen(tmp);
}
